package com.cykj.pos.service.impl;

import com.cykj.common.annotation.DataSource;
import com.cykj.common.enums.DataSourceType;
import com.cykj.pos.domain.dto.CashOutDTO;
import com.cykj.pos.domain.dto.SubmitGrantDetailDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import com.cykj.pos.mapper.BizCashoutFeeMapper;
import com.cykj.pos.domain.BizCashoutFee;
import com.cykj.pos.service.IBizCashoutFeeService;

import java.util.List;
import java.util.Map;

/**
 * 提现费用管理Service业务层处理
 *
 * @author weijianbo
 * @date 2021-03-16
 */
@Service
public class BizCashoutFeeServiceImpl extends ServiceImpl<BizCashoutFeeMapper, BizCashoutFee> implements IBizCashoutFeeService {

    @Autowired
    private  BizCashoutFeeMapper bizCashoutFeeMapper;
    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<BizCashoutFee> queryList(BizCashoutFee bizCashoutFee) {
        LambdaQueryWrapper<BizCashoutFee> lqw = Wrappers.lambdaQuery();
        if (bizCashoutFee.getMinAmount() != null){
            lqw.eq(BizCashoutFee::getMinAmount ,bizCashoutFee.getMinAmount());
        }
        if (bizCashoutFee.getServiceCharge() != null){
            lqw.eq(BizCashoutFee::getServiceCharge ,bizCashoutFee.getServiceCharge());
        }
        if (bizCashoutFee.getRate() != null){
            lqw.eq(BizCashoutFee::getRate ,bizCashoutFee.getRate());
        }
        if (bizCashoutFee.getCashoutType() != null){
            lqw.eq(BizCashoutFee::getCashoutType ,bizCashoutFee.getCashoutType());
        }
        return this.list(lqw);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public BizCashoutFee getCashoutFeeByType(CashOutDTO cashOutDTO) {
        return bizCashoutFeeMapper.getCashoutFee(cashOutDTO.getUserId());
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public BizCashoutFee getXinLongCashoutFeeByType(SubmitGrantDetailDTO submitGrantDetailDTO) {
       return bizCashoutFeeMapper.getCashoutFee(submitGrantDetailDTO.getUserId());
    }
}
